const  express  =  require("express")
const  router  =  express.Router()
const conn = require("../mysql")


router.get('/cartdelete', (req, res) => {
    let { name } = req.query;
    let sql = `delete from cart where name='${name}'`
    conn.query(sql, (err, data) => {


    })
    sql = `select * from cart`;
    conn.query(sql, (err, data) => {
        res.send({ code: 1, data });
    })
})

router.get('/cartt', (req, res) => {
    console.log('get');

    // let {type} = req.query;
    let sql = `select * from cart`
    conn.query(sql, (err, data) => {
        if (err) {
            console.log(err);
            return;
        }
        if (data.length) {
            res.send({
                code: 1,
                data
            })
            return;
        }
        res.send({
            code: 0
        })

    })
})

module.exports  =  router;